package ${package}.${moduleName}.service.impl;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;


import java.util.List;


@Service
@RequiredArgsConstructor
@Slf4j
public class ${ClassName}ApplicationService {
    private final ${ClassName}Repository ${className}Repository;

   @Transactional(readOnly = true)
    public PagedResult<${ClassName}> page(Paged paged) {
        PagedResult<${ClassName}>  result = ${className}Repository.page(paged);
        return result;
    }

    @Transactional(rollbackFor = Exception.class)
    public ${ClassName} ofId(String id){
       ${ClassName} ${className} = ${className}Repository.ofId(id);
       return ${className};
    }

    @Transactional(rollbackFor = Exception.class)
    public void add(Add${ClassName}Command command){
       ${ClassName} ${className} = ${ClassName}.newInstance();
       ${className}Repository.save(${className});
    }

    @Transactional(rollbackFor = Exception.class)
    public void edit(Edit${ClassName}Command command){
        ${ClassName} ${className} = ${className}Repository.ofId(command.getId());
        ${className}.edit();
        ${className}Repository.save(${className});
    }
}